<?php
namespace app\stores\model\member;
use app\beautiful\model\member\MemberCouponModel;
use app\common\model\CommonModel;
use app\common\model\ShopModel;

class MemberSearchModel extends CommonModel{
    protected  $name = 'member_search';
    protected  $pk   = 'search_id';

    /**
     * 模型写入前事件（钩子函数）
     */
    public static function onBeforeInsert($model)
    {
        $model->set("add_time", date('Y-m-d H:i:s'));
        $model->set("add_ip", request()->ip());
    }
    public function getList($where,$order,$page=0,$limit=0,$group=''){
        $query = $this->where($where)->field("content,max(search_id) as search_id");
        $count = $query->count();
        if($group) $query=$query->group('content');
        $query = $query->order($order);
        if($page>0) $query = $query->page($page);
        if($limit>0) $query = $query->limit($limit);
        $list = $query->select()->toArray();
        if(!empty($list)){
            foreach ($list as $k=>$v){

            }
        }
        return compact('count','list');
    }
    public function del($where){
        $re = $this->where($where)->delete();
        return $re;

    }
}
